home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / public / ghostscript / src / gsuid.h < prev    next >
C/C++ Source or Header  |  1994-08-01  |  2KB  |  61 lines

  1. /* Copyright (C) 1992 Aladdin Enterprises.  All rights reserved.
  2.  
  3. This file is part of Ghostscript.
  4.  
  5. Ghostscript is distributed in the hope that it will be useful, but
  6. WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  7. to anyone for the consequences of using it or for whether it serves any
  8. particular purpose or works at all, unless he says so in writing.  Refer
  9. to the Ghostscript General Public License for full details.
  10.  
  11. Everyone is granted permission to copy, modify and redistribute
  12. Ghostscript, but only under the conditions described in the Ghostscript
  13. General Public License.  A copy of this license is supposed to have been
  14. given to you along with Ghostscript so you can know your rights and
  15. responsibilities.  It should be in a file named COPYING.  Among other
  16. things, the copyright notice and this notice must be preserved on all
  17. copies.  */
  18.  
  19. /* gsuid.h */
  20. /* Unique id definitions for Ghostscript */
  21.  
  22. #ifndef gsuid_INCLUDED
  23. #  define gsuid_INCLUDED
  24.  
  25. /* A unique id (uid) may be either a UniqueID or an XUID. */
  26. /* (XUIDs are a Level 2 feature.) */
  27. typedef struct gs_uid_s {
  28.     union {
  29.         long id;    /* UniqueID, size == 0 */
  30.         long *xvalues;    /* XUID, size != 0 */
  31.     } u;
  32.     ushort size;
  33. } gs_uid;
  34.  
  35. /* A UniqueID of -1 is an indication that there is no uid. */
  36. #define uid_is_valid(puid)\
  37.   !((puid)->size == 0 && (puid)->u.id == -1)
  38. #define uid_set_invalid(puid)\
  39.   ((puid)->size = 0, (puid)->u.id = -1)
  40.       
  41. /* Initialize a uid. */
  42. #define uid_set_UniqueID(puid, idv)\
  43.   ((puid)->size = 0, (puid)->u.id = idv)
  44. #define uid_set_XUID(puid, pvalues, siz)\
  45.   ((puid)->size = siz, (puid)->u.xvalues = pvalues)
  46.  
  47. /* Compare two uids for equality. */
  48. #define uid_equal(puid1, puid2)\
  49.   ((puid1)->size == (puid2)->size &&\
  50.    ((puid1)->size ?\
  51.     !memcmp((const char *)(puid1)->u.xvalues,\
  52.         (const char *)(puid2)->u.xvalues, (puid1)->size) :\
  53.     (puid1)->u.id == (puid2)->u.id))
  54.  
  55. /* Free the XUID array of a uid if necessary. */
  56. #define uid_free(puid, proc_free, cname)\
  57.   if ( (puid)->size )\
  58.     (proc_free)((char *)(puid)->u.xvalues, (puid)->size, sizeof(long), cname)
  59.  
  60. #endif                    /* gsuid_INCLUDED */
  61.